<!--
 * @Author: liuyonghu
 * @Date: 2021-05-24 16:24:52
 * @LastEditTime: 2021-05-26 14:47:48
 * @LastEditors: liuyonghu
 * @Description: 
 * @FilePath: \vue2amaptest\src\components\home.vue
-->

<template>
  <div>this is home page</div>
</template>

<script>
export default {
  name: "home",
  beforeCreate() {
    console.log(" -- home before created");
    let amaps = document.querySelector("#amaps");
    if (amaps) {
      document.head.removeChild(amaps);
    }
    window.callback = () => {
      console.log(" call back", window.AMap);
    };
    let src = `https://webapi.amap.com/maps?v=1.4.15&key=${"e7152df832f53aad42466f79b0630139"}&plugin=AMap.Geolocation,AMap.Autocomplete&callback=callback`;
    amaps = document.createElement("script");
    amaps.type = "text/javascript";
    amaps.async = true;
    amaps.defer = true;
    amaps.src = src;
    amaps.id = "amaps";
    amaps.onload = () => {
      console.log(" on load");
    };
    document.head.appendChild(amaps);
  },
};
</script>

<style>
</style>